package com.hw.servlet;

import com.google.gson.Gson;

import javax.servlet.ServletException;
import javax.servlet.ServletInputStream;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.util.Enumeration;

@WebServlet(name = "CCServlet",urlPatterns = "/ccc")
public class CCServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        BufferedReader in = new BufferedReader(new InputStreamReader(request.getInputStream()));
        StringBuffer buffer = new StringBuffer();
        String msg = null;
        Enumeration<String> sa= request.getParameterNames();
        while (sa.hasMoreElements()){
            System.out.println(sa.nextElement());
        }

        while((msg=in.readLine()) != null){
            System.out.println(msg);
            buffer.append(msg);
        }
        System.out.println("params："+buffer);



    }
}
